package com.teira.rhrrealstate.session;

import com.teira.rhrrealstate.entity.*;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("clienteHome")
public class ClienteHome extends EntityHome<Cliente> {

	@In(create = true)
	TipoDocumentoHome tipoDocumentoHome;

	public void setClienteId(Long id) {
		setId(id);
	}

	public Long getClienteId() {
		return (Long) getId();
	}

	@Override
	protected Cliente createInstance() {
		Cliente cliente = new Cliente();
		return cliente;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
		TipoDocumento tipoDocumento = tipoDocumentoHome.getDefinedInstance();
		if (tipoDocumento != null) {
			getInstance().setTipoDocumento(tipoDocumento);
		}
	}

	public boolean isWired() {
		return true;
	}

	public Cliente getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

}
